package cn.design.realize;

import javax.naming.Name;

/**
 * @author dlq
 * @description
 *      具体中介者(ConcreteMediator)角色：实现了抽象中介者所声明的事件方法。具体中介者知晓所有的具体同事类，并负责具体的协调各同事对象的交互关系
 * @date 2020/10/13 10:34
 * @since 1.0
 */
public class ConcreteMediator implements Mediator{
    //具体房东类
    private ConcreteColleagueFangDong fangDong;
    //具体租户类
    private ConcreteColleagueZuHu zuHu;

    //完成房东和组合的交互
    @Override
    public void sendMessage(String msg, ColleaguePerson person) {
        if (person == fangDong){
            //中介获取到房东回应消息，告知给租户
            System.out.println("中介获取到房东回应消息，告知给租户.......");
            zuHu.getMessage(msg);

        }
        if (person == zuHu){
            //中介获取到租户说的消息，告知给房东
            System.out.println("中介获取到租户说的消息，告知给房东......");
            fangDong.getMessage(msg);

        }
    }

    public ConcreteColleagueFangDong getFangDong() {
        return fangDong;
    }

    public void setFangDong(ConcreteColleagueFangDong fangDong) {
        this.fangDong = fangDong;
    }

    public ConcreteColleagueZuHu getZuHu() {
        return zuHu;
    }

    public void setZuHu(ConcreteColleagueZuHu zuHu) {
        this.zuHu = zuHu;
    }
}
